//https://leetcode.cn/problems/counting-bits/
class Solution {
    public int[] countBits(int n) {
        int[] ret = new int[n+1];
        for(int i = 1; i <= n; i++) {
            int x = i;
            while(x != 0) {
                if((x & 1) == 1) {
                    ret[i]++;
                }
                x >>= 1;
            }
        }
        return ret;
    }
}